<?php
  ////////////////////////////////////////
  //                Note                //
  //  This file is no longer necessary  // 
  //       and can now be deleted       //
  ////////////////////////////////////////
  
include('../includes/smarty.php');
include_once('../config.php');

session_start();

$ADMIN = new Admin();
$EMPLOYER = new Employer();

if(isset($_SESSION["id"]))
{
	$row = $ADMIN->validate_admin_session($_SESSION["id"]);
	
	if($row)
	{	
		//	Show the screen.
		$ADMIN->update_lastvisit($_SESSION["id"]);
		
		//	Get the existing companies.
		$companies = $EMPLOYER->get_companies();
		
		$smarty->assign('title', 		'Admin: Select a Company');
		$smarty->assign('path', 		$site);
		$smarty->assign('body', 		'main/admin/selectCompany.tpl');
		$smarty->assign('companylist', 	$companies);
		$smarty->assign('message',		'');
		
		$smarty->display('admin.tpl');
		
		if(!empty($_POST))
		{
			$companyID = $_POST["companyName"];	//posts company name
			$_SESSION['companyID'] = $companyID;
			$companyInfo = $EMPLOYER->get_company_info($companyID);
		}
		
		if(!empty($companyID) && $companyInfo['id'] == $companyID)
		{
			header('Location: updateCompany.php');
		}
		
	}
		else
	{
		//	Kill the current session, and show the login screen.
		session_destroy();
		header('Location: ../admin/index.php');
	}
}